﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.RB
{
    class Class8
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string t = ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("养老金领却类型").ToString();

            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["领取年龄"];

            string s2 = ppa.PolicyActing.Policy.SelectedColRateFactors["领取期限"];

            int a = int.Parse(s.Substring(0, 2));

            int r = s2 == "20年" ? a + 20 : 85;

            if (ppa.Age >= a && ppa.Age < r)
            {

                if (t == "增额年金")
                {
                    da.Value = 0;
                }
                else
                {
                    da.Value = ppa.Amount;
                }
            }

            if (ppa.Age == r)
            {
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            string s = ppa.PolicyActing.Policy.SelectedColRateFactors["领取年龄"];

            string s2 = ppa.PolicyActing.Policy.SelectedColRateFactors["领取期限"];

            int a = int.Parse(s.Substring(0, 2));

            int r = s2 == "20年" ? ppa.SchemePeriodActing.SchemeActing.Scheme.Insurant.Age + 20 : 85;

            if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
            {
                ppa.SchemePeriodActing.InsurantStates.Add("身故");

                if (ppa.Age < a)
                {
                    da.Value = ppa.TotalFee ;
                }

                ppa.IsCurrentFinish = true;
            }

            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                if (ppa.Age < a)
                {
                    da.Value += ppa.TotalFee;
                }
                else
                {
                    da.Value += (r - ppa.Age) * ppa.Amount;
                }

                ppa.IsCurrentFinish = true;
            }

            
        }
    }
}
